package com.zp.self.springboot.z_启动过程.组件;

import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * @author By ZengPeng
 * @Description 就是在容器刷新之前调用该类的 initialize 方法
 * 并将 ConfigurableApplicationContext 类的实例传递给该方法
 * @date in  2021/4/4 15:37
 * @Modified By
 */
public class ApplicationContextInitializer分析 {

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(ApplicationContextInitializer分析.class);
        application.addInitializers(new MyApplicationContextInitializer());
        application.run(args);
    }


}
@Order(Ordered.HIGHEST_PRECEDENCE)
class MyApplicationContextInitializer implements ApplicationContextInitializer {
    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        System.out.println("-----MyApplicationContextInitializer initialize-----");
    }
}